﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ft_module_parser
{
    class XPvParam
    {
        public static void Process()
        {
            if (Directory.Exists("pv_param"))
            Directory.Delete("pv_param", true);
            Directory.CreateDirectory("pv_param");
            foreach (var file in Directory.GetFiles("x_pvparam\\", "*.txt", SearchOption.AllDirectories))
            {
                if (file.Contains("dof"))
                {
                    int pvid = int.Parse(Path.GetFileName(file).Substring(2, 3));
                    string basepath = "pv_param\\pv"+pvid;
                    Directory.CreateDirectory(basepath);
                    File.Copy(file, basepath + "\\dof.txt");
                }
                if (file.Contains("bloom"))
                {
                    int pvid = int.Parse(Path.GetFileName(file).Substring(5, 3));
                    pvid = pvid + 800;
                    string basepath = "pv_param\\pv" + pvid;
                    Directory.CreateDirectory(basepath);
                    File.Copy(file, basepath + "\\bloom.txt");
                }
                if (file.Contains("cc"))
                {
                    int pvid = int.Parse(Path.GetFileName(file).Substring(5, 3));
                    pvid = pvid + 800;
                    string basepath = "pv_param\\pv" + pvid;
                    Directory.CreateDirectory(basepath);
                    File.Copy(file, basepath + "\\cc.txt");
                }
                if (file.Contains("stage_light"))
                {
                    int pvid = int.Parse(Path.GetFileName(file).Substring(5, 3));
                    pvid = pvid + 800;
                    string basepath = "pv_param\\pv" + pvid;
                    Directory.CreateDirectory(basepath);
                    File.Copy(file, basepath + "\\stage_light.txt");
                }
                if (file.Contains("chara_light"))
                {
                    int pvid = int.Parse(Path.GetFileName(file).Substring(5, 3));
                    pvid = pvid + 800;
                    string basepath = "pv_param\\pv" + pvid;
                    Directory.CreateDirectory(basepath);
                    File.Copy(file, basepath + "\\chara_light.txt");
                }
                if (file.Contains("item_light"))
                {
                    int pvid = int.Parse(Path.GetFileName(file).Substring(5, 3));
                    pvid = pvid + 800;
                    string basepath = "pv_param\\pv" + pvid;
                    Directory.CreateDirectory(basepath);
                    File.Copy(file, basepath + "\\item_light.txt");
                }
                if (file.Contains("chara_edit_light"))
                {
                    int pvid = int.Parse(Path.GetFileName(file).Substring(5, 3));
                    pvid = pvid + 800;
                    string basepath = "pv_param\\pv" + pvid;
                    Directory.CreateDirectory(basepath);
                    File.Copy(file, basepath + "\\chara_edit_light.txt");
                }
            }
        }
    }
}
